#!/usr/bin/env node
const { program } = require("commander");
const { prompt } = require("inquirer");
const shell = require("shelljs")
const cmdAction = async () => {
    var test = "";
    const answers = await prompt([
        {
            type: "input",
            name: "cmd",
            message: "请输入你要执行的命令？"
        },
        {
            type: "rawlist",
            choices: ['vue', 'react'],
            name: "type",
            message: "请选择你想使用的插件？"
        },
        {
            type: "checkbox",
            choices: ['sass', 'css', 'scss', 'less'],
            name: "precompile",
            message: "请选择你要使用的预编译包？"
        },
    ])
    console.log(answers);
    if (answers.type === 'vue') {
        test = 'vue create hello-world';
    } else if (answers.type === 'react') {
        test = 'create-react-app demo1';
    }
    shell.exec(test, (code, stdout, stderr) => {
        console.log('Exit code:', code);
        console.log('Program output:', stdout);
        console.log('Program stderr:', stderr);
    })
}
program.version('1.0.2').command("init").action(cmdAction);
program.parse(process.argv)

